//
//  ParticipatorListCell.m
//  ChatDemo-UI2.0
//
//  Created by Sylar on 16/8/2.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "ParticipatorListCell.h"


@implementation ParticipatorListCell
{
    //UILabel *nameLabel;
    
    //XZHeaderImageView *headImg;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(59, 15, 150, 16)];
        [self.nameLabel setFont:[UIFont systemFontOfSize:14]];
        [self.nameLabel setTextColor:RGBCOLOR(59, 59, 59)];
        self.nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.nameLabel];
        
        self.headImg = [[XZHeaderImageView alloc]initWithFrame:CGRectMake(15, 6, 34, 34)];
        [self.contentView addSubview:self.headImg];
        
        UIView *line=[[UIView alloc]initWithFrame:CGRectMake(56, 43.5 , SCREENWIDTH, 0.5)];
        line.tag = 60;
        line.backgroundColor = [UIColor colorWithHexString:@"#DEDEDE"];
        [self.contentView addSubview:line];
        
        [self.contentView setBackgroundColor:[UIColor whiteColor]];
        
    }
    return self;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)creatCell:(StudentsModel *)model {
    
    NSString *nameText;
    
    if (model.username) {
        nameText = model.username;
    }else if (model.studentname) {
        nameText = model.studentname;
    }
    
    self.nameLabel.text = nameText;
    
    NSString *logoStr;
    if (model.logo) {
        logoStr = model.logo;
    }else if (model.studentlogo) {
        logoStr = model.studentlogo;
    }
    
    
    //NSString *nameStr = model.username;
    
    if (nameText.length > 2) {
        nameText = [nameText substringFromIndex:nameText.length - 2];
    }
    
     if (![logoStr hasPrefix:@"http"] && logoStr) {
        logoStr = [REQUESTIMAGEURL stringByAppendingString:logoStr];
    }
    
    [self.headImg.headImage sd_setImageWithURL:[NSURL URLWithString:logoStr]];
    self.headImg.namelabel.text = nameText;
    self.headImg.flag = model.logotype == 1?YES:NO;
    self.headImg.headPressed = ^(){
        
    };
    
    
}
@end
